// pages/query/query.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name: '',
    identityCard: '',
    avatarUrl:'',
    nickName:'',
    matchCategoryGroupName:"",
    entryCode:"",
    matchCategoryGroupCode:"",
    performance:"",
    numberList:["B2003","B2005",
      "B2019", "B2035", "B2051","B2079","B2085","B2094","B2096","B2104",
      "B2094","B2096","B2109","B2133","B2148","B2171", "B2172","B2173",
      "B2177","B2183","B2208","B2227", "B2254", "B2271","B2292"
      ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      name: options.name,
      avatarUrl: options.avatarUrl,
      nickName: options.nickName,
      matchCategoryGroupName: options.matchCategoryGroupName,
      entryCode: options.entryCode,
      matchCategoryGroupCode: options.matchCategoryGroupCode,
      performance: options.performance
    });
  },

  handleCardNum(cardNum) {
    const newNum = cardNum.replace(/^(.{4})(?:\d+)(.{4})$/,"$1******$2");
    this.setData({
      identityCard: newNum
   })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  getEntryCode: function(){
    const { name, identityCard, avatarUrl, nickName, matchCategoryGroupName ,entryCode, matchCategoryGroupCode} = this.data
    wx.navigateTo({
      url: `../person/person?name=${name}&identityCard=${identityCard}&avatarUrl=${avatarUrl}&nickName=${nickName}&matchCategoryGroupName=${matchCategoryGroupName}&entryCode=${entryCode}&matchCategoryGroupCode=${matchCategoryGroupCode}`
    });
  },

  getPerformance: function(){
    const { name, matchCategoryGroupCode, entryCode, performance, numberList} = this.data
    console.log(numberList.indexOf(entryCode));
    if(numberList.indexOf(entryCode)>0){
      wx.showToast({
        title: '暂无证书信息',
        icon: 'error',
        duration: 2000
        });
        return false
    }
    wx.navigateTo({
      url: `../performanceimage/performanceimage?entryCode=${entryCode}`
    });

  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})